package com.xyht.sca_s.student_manage_system.modules.teachAndStaffCheckInApplication.config;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xyht.sca_s.student_manage_system.modules.teachAndStaffCheckInApplication.entity.SmsTeachAdministrativeStaffCheckInApplicationProcess;
import com.xyht.sca_s.student_manage_system.modules.teachAndStaffCheckInApplication.mapper.SmsTeachAdministrativeStaffCheckInApplicationProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class ProcessApplication {
    @Autowired
    private SmsTeachAdministrativeStaffCheckInApplicationProcessMapper smsTeachAdministrativeStaffCheckInApplicationProcessMapper;

    private String[] departmentNameArray = {"人事部", "分管领导", "后勤处",
            "财务处"};

    @Bean
    public void teachAndStaffCheckInApplication() {
        List<SmsTeachAdministrativeStaffCheckInApplicationProcess> processList =
                smsTeachAdministrativeStaffCheckInApplicationProcessMapper.selectList(new QueryWrapper<>());
        if (processList == null || processList.size() < 1) {
            int sort = 1;
            for (String departmentName : departmentNameArray) {
                SmsTeachAdministrativeStaffCheckInApplicationProcess addProcess =
                        new SmsTeachAdministrativeStaffCheckInApplicationProcess();
                addProcess.setProcessName(departmentName);//流程节点名称
                addProcess.setIsUse(true);
                addProcess.setIsStamp(false);
                addProcess.setIsSign(true);
                addProcess.setSort(sort++);
                smsTeachAdministrativeStaffCheckInApplicationProcessMapper.insert(addProcess);
            }
        }
    }
}
